/*
 *@Author: 张楚
 *@Date: 2021-08-17 10:20:30
 *@Description: 待我查阅 详情
*/

import 'package:flutter/material.dart';
import 'package:totaldemo/project/official_detail/reply_index.dart';
import 'package:totaldemo/utils/util.dart';
import 'package:get/get.dart';

class WaitBrowseDetailsPage extends StatefulWidget {
  const WaitBrowseDetailsPage({Key key}) : super(key: key);
  @override
  _WaitBrowseDetailsPageState createState() => _WaitBrowseDetailsPageState();
}

class _WaitBrowseDetailsPageState extends State<WaitBrowseDetailsPage> {
  bool isShow = false; //false不展开
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('公文详情'),
        ),
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Padding(
                padding: EdgeInsets.only(bottom: 18, right: 14, left: 15),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '转发内容',
                          style: TextStyle(
                              fontSize: 14,
                              color: Color(0xff333333),
                              fontWeight: FontWeight.w500),
                        ),
                        isShow
                            ? IconButton(
                                icon: Icon(
                                  Icons.keyboard_arrow_right,
                                  color: Color(0xff999999),
                                  size: 20,
                                ),
                                onPressed: () {
                                  setState(() {
                                    isShow = !isShow;
                                  });
                                })
                            : IconButton(
                                icon: Icon(
                                  Icons.arrow_downward,
                                  color: Color(0xff999999),
                                  size: 15,
                                ),
                                onPressed: () {
                                  setState(() {
                                    isShow = !isShow;
                                  });
                                })
                      ],
                    ),
                    Padding(
                      padding: const EdgeInsets.symmetric(vertical: 10),
                      child: RichText(
                          text: TextSpan(
                              // style: DefaultTextStyle.of(context).style,
                              style: TextStyle(
                                fontSize: 12,
                                color: Color(0xff999999),
                              ),
                              children: [
                            TextSpan(
                              text: '来自于:',
                            ),
                            TextSpan(
                              text: '    向国庆',
                            ),
                          ])),
                    ),
                    DefaultTextStyle(
                      style: TextStyle(
                        fontSize: 12,
                        color: Color(0xff999999),
                      ),
                      child: Row(
                        // mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('发件人意见:'),
                          SizedBox(
                            width: 10,
                          ),
                          Expanded(
                            child: Padding(
                                padding: EdgeInsets.only(right: 20, top: 2),
                                child: Text(
                                    '16465465s465as4d65as4d65as4d65as4d65as4d65a4d65a4d654a65d4a65d5as4d65as4d65as4d65a4d65a4d654a65d4a65as4d65as4d65as4d65a4d65a4d654a65d4a64a65d46a54d654',
                                    overflow: isShow
                                        ? TextOverflow.ellipsis
                                        : TextOverflow.visible)
                                // : Text(
                                //     '16465465s465as4d65as4d65as4d65as4d65as4d65a4d65a4d654a65d4a65d5as4d65as4d65as4d65a4d65a4d654a65d4a65as4d65as4d65as4d65a4d65a4d654a65d4a64a65d46a54d654',
                                //     // overflow: TextOverflow.ellipsis,
                                //     maxLines: 5,
                                //   )
                                ),
                          )
                        ],
                      ),
                    )
                    // : DefaultTextStyle(
                    //     style: TextStyle(
                    //       fontSize: 12,
                    //       color: Color(0xff999999),
                    //     ),
                    //     child: Row(
                    //       mainAxisAlignment: MainAxisAlignment.start,
                    //       crossAxisAlignment: CrossAxisAlignment.start,
                    //       children: [
                    //         Text('发件人意见:'),
                    //         SizedBox(
                    //           width: 10,
                    //         ),
                    //         Expanded(
                    //           child: Padding(
                    //             padding: EdgeInsets.only(right: 20),
                    //             child: Text(
                    //               '16465465s465as4d65as4d65as4d65as4d65as4d65a4d65a4d654a65d4a65d5as4d65as4d65as4d65a4d65a4d654a65d4a65as4d65as4d65as4d65a4d65a4d654a65d4a64a65d46a54d654',
                    //               // overflow: TextOverflow.ellipsis,
                    //               maxLines: 5,
                    //             ),
                    //           ),
                    //         )
                    //       ],
                    //     ),
                    //   )
                  ],
                ),
              ),

              //公文内容部分
              Container(
                  // color: colos,
                  height: 81,
                  decoration: BoxDecoration(
                    border: Border(
                      right: BorderSide.none,
                      left: BorderSide.none,
                      top: BorderSide(
                          color: Color(0x30666666),
                          width: 1,
                          style: BorderStyle.solid),
                      bottom: BorderSide(
                          color: Color(0x30666666),
                          width: 1,
                          style: BorderStyle.solid),
                    ),
                  ),
                  child: Stack(
                    children: [
                      Positioned(
                          top: -2,
                          right: 0,
                          child: Image.asset(
                            Util.getUrl('official_detail_urgent_one.png'),
                            width: 45,
                            height: 45,
                          )),
                      Padding(
                        padding: EdgeInsets.only(
                            top: 20, bottom: 20, right: 15, left: 15),
                        child: Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  '00000001',
                                  style: TextStyle(
                                    fontSize: 12,
                                    color: Color(0xff666666),
                                  ),
                                ),
                                Text(
                                  '机密一年',
                                  style: TextStyle(
                                    color: Color(0xff666666),
                                    fontSize: 12,
                                  ),
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 5,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.end,
                              children: [
                                Text(
                                  '特急',
                                  style: TextStyle(
                                    color: Color(0xffff0000),
                                    fontSize: 12,
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      )
                    ],
                  )),

              //内容标题部分
              Container(
                padding: EdgeInsets.symmetric(horizontal: 70),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text(
                      '国务院文件',
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.w500,
                        color: Color(0xffFF534B),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 4, bottom: 10),
                      child: Text(
                        '国函〔2014〕28号',
                        style: TextStyle(
                          fontSize: 12,
                          fontWeight: FontWeight.w500,
                          color: Color(0xff666666),
                        ),
                      ),
                    ),
                    Text(
                      '国务院关于同意建立不动产登记工作部际联席会议制度的批复',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 14,
                        color: Color(0xff333333),
                      ),
                    ),
                  ],
                ),
              ),
              //内容
              // Padding(
              //   padding: EdgeInsets.only(top: 5, right: 16, left: 12),
              //   child: Column(
              //     crossAxisAlignment: CrossAxisAlignment.start,
              //     children: [
              //       Text(
              //         '国土资源部：　',
              //         style: TextStyle(
              //           fontSize: 14,
              //           color: Color(0xff333333),
              //         ),
              //       ),
              //       SizedBox(
              //         height: 10,
              //       ),
              //       Text(
              //         '　  你部《关于建立不动产登记工作部际联席会议制度有关问题的请示》（国土资发〔2014〕15号）收悉。现批复如下：',
              //         style: TextStyle(
              //           fontSize: 14,
              //           color: Color(0xff666666),
              //         ),
              //       ),
              //       Padding(
              //         padding: const EdgeInsets.only(top: 5, bottom: 19),
              //         child: Text(
              //           '      同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作',
              //           style: TextStyle(
              //             fontSize: 14,
              //             color: Color(0xff333333),
              //           ),
              //         ),
              //       ),
              //     ],
              //   ),
              // ),

              //根据后端返回数据
              //内容2
              Container(
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.only(left: 15, right: 15),
                child: Text(
                    '  同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作同意建立由国土资源部牵头的不动产登记工作部际联席会议制度。联席会议不刻制印章，不正式行文，请按照国务院有关文件精神认真组织开展工作'),
              ),
              //查看节点
              Container(
                padding: const EdgeInsets.only(right: 18),
                child: DefaultTextStyle(
                  style: TextStyle(fontSize: 14, color: Color(0xff333333)),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    // mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text('国务院'),
                      SizedBox(
                        height: 10,
                      ),
                      Text('2020年12月28日'),
                    ],
                  ),
                ),
              ),
              //底部附件
              Container(
                // margin: EdgeInsets.only(left: 18, right: 14),
                child: Column(
                  children: [
                    Padding(
                      padding: EdgeInsets.only(left: 18, right: 14),
                      child: Row(
                        children: [
                          Icon(Icons.attach_email, size: 20),
                          Expanded(
                              child: Text('不动产登记工作部际联席会议动产登记工作部际作部际作部际联席会议制制度',
                                  overflow: TextOverflow.ellipsis,
                                  style: TextStyle(
                                      fontSize: 14, color: Color(0xff666666)))),
                          TextButton(
                              onPressed: () {},
                              child: Text(
                                '查看',
                                style: TextStyle(
                                    fontSize: 14,
                                    decoration: TextDecoration.underline,
                                    color: Color(0xff2CA0FF)),
                              ))
                        ],
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
        bottomNavigationBar: FixBtm);
  }

  Widget FixBtm = Container(
    padding: EdgeInsets.only(left: 18, right: 14),
    height: 44,
    color: Color(0xffE7E8F3),
    child: DefaultTextStyle(
      style: TextStyle(
        fontSize: 14,
        color: Color(0xff373F9B),
      ),
      child: Row(
        // mainAxisAlignment: MainAxisAlignment.center,
        // crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          IconText(
              icon: Icons.replay,
              title: '查看节点',
              function: () {
                print('object');
              }),
          Spacer(),
          IconText(
              icon: Icons.replay,
              title: '回复',
              function: () {
                // print('object');
                Get.to(() => ReplyCommentPage());
              }),
          SizedBox(width: 20),
          IconText(
              icon: Icons.report_sharp,
              title: '转发',
              function: () {
                print('object');
              }),
        ],
      ),
    ),
  );
}

Widget IconText({IconData icon, String title, Function function}) {
  return GestureDetector(
    behavior: HitTestBehavior.opaque,
    onTap: function,
    child: Row(
      children: [
        Icon(
          icon,
          size: 18,
        ),
        Text(title)
      ],
    ),
  );
}
